const express = require("express")
const app = express()
const loginRouter = require("./router/login.cjs")
const homeRouter = require("./router/home.cjs")
const myRouter = require("./router/my.cjs")
const uploader = require("./router/routerImg/uploader.cjs")
const speak = require("./router/comment.cjs")
const cors = require("cors")
const multer = require("multer")
// 配置解析表单数据的中间件
// parse application/x-www-form-urlencoded
app.use(express.urlencoded({extended:false}))
// parse application/json
app.use(express.json())
// 配置cors解决跨域问题
app.use(cors())
// app.use(multer)
app.use(express.static('images'))
// 登录路由
app.use("/api",loginRouter)
// 上传文件
app.use(uploader)
// 首页
app.use(homeRouter)
app.use(speak)
// my
app.use(myRouter)

app.listen(8081,()=>{
  console.log("at http://127.0.0.1:8081");
})